﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class manager_login : System.Web.UI.Page
{
    private EncryptMD5 encryptMD5 = null;
    private Connection myConnection = null;

    protected void Page_Load(object sender, EventArgs e)
    {
        encryptMD5 = new EncryptMD5();
    }


    protected void btn_login_Click(object sender, ImageClickEventArgs e)
    {
        string user = txt_username.Text.ToString().Trim();
        string pass = txt_password.Text.ToString().Trim();

        if (LocalVariables.isNullorEmpty(user))
        {
            lbl_msg.Text = LocalVariables.USERNAME_FAILURE;
            return;
        }

        if (LocalVariables.isNullorEmpty(pass))
        {
            lbl_msg.Text = LocalVariables.PASSWORD_FAILURE;
            return;
        }

        myConnection = new Connection();
        if (myConnection.loginManager(user, encryptMD5.encrypt(pass), "Manager"))
        {
            Session.Timeout = 60000;
            Session["username"] = user;
            Response.Redirect("index.aspx");
        }
        else
        {
            lbl_msg.Text = LocalVariables.CONNECT_FAILURE;
        }
    }
}
